<?php
declare(strict_types=1);

namespace LowCode\Naive;

use LowCode\Naive;
use LowCode\Node;
use LowCode\Support\JsExp;
use LowCode\Traits\Props\HasDefaultValue;
use LowCode\Traits\Props\HasDisabled;
use LowCode\Traits\Props\HasLoading;
use LowCode\Traits\Props\HasRound;
use LowCode\Traits\Props\HasSize;
use LowCode\Traits\Slots\HasSlotIcon;

/**
 * NSwitch 开关组件
 * @method static static make(string|int|bool|JsExp $value = null) NSwitch组件
 */
class NSwitch extends Naive
{

    use HasRound, HasDisabled, HasSize, HasDefaultValue, HasLoading;

    use \LowCode\Traits\Props\HasValueModel, \LowCode\Traits\Events\HasOnUpdateValue;

    use HasSlotIcon;

    /**
     * @param string|int|bool|JsExp|null $value
     */
    public function __construct(string|int|bool|JsExp $value = null)
    {
        parent::__construct("NSwitch");
        $this->value($value);
    }

    /**
     * 设置组件是默认值
     * @param string|int|bool|JsExp $value
     * @return $this
     */
    public function value(string|int|bool|JsExp $value = null): static
    {
        return $this->prop('value', $value);
    }

    /**
     * 选中时对应的值
     * @param string|bool|int|JsExp $value
     * @return $this
     */
    public function checkedValue(string|bool|int|JsExp $value = null): static
    {
        return $this->prop('checkedValue', $value);
    }

    /**
     * 按钮是否有橡皮筋效果
     * @param bool|JsExp $bool
     * @return $this
     */
    public function rubberBand(bool|JsExp $bool = true): static
    {
        return $this->prop('rubberBand', $bool);
    }

    /**
     * 未选中时对应的值
     * @param string|bool|int|JsExp $value
     * @return $this
     */
    public function uncheckedValue(string|bool|int|JsExp $value = null): static
    {
        return $this->prop('uncheckedValue', $value);
    }

    /**
     * 创建轨道样式的函数
     * @param string $event (info: { focused: boolean, checked: boolean }) => (CSSProperties | string)
     * @return $this
     */
    public function railStyle(string $event = "(info) => {}", string $id = null): static
    {
        return $this->jsFunction('railStyle', $event, $id);
    }


    /**
     * 设置 slot checked 内容
     * @param Node $node
     * @return $this
     */
    public function slotChecked(Node $node): static
    {
        return $this->addSlot($node,'checked');
    }

    /**
     * 设置 slot checkedIcon 内容
     * @param Node $node
     * @return $this
     */
    public function slotCheckedIcon(Node $node): static
    {
        return $this->addSlot($node,'checkedIcon');
    }

    /**
     * 设置 slot unchecked 内容
     * @param Node $node
     * @return $this
     */
    public function slotUnchecked(Node $node): static
    {
        return $this->addSlot($node,'unchecked');
    }

    /**
     * 设置 slot uncheckedIcon 内容
     * @param Node $node
     * @return $this
     */
    public function slotUncheckedIcon(Node $node): static
    {
        return $this->addSlot($node,'uncheckedIcon');
    }


}
